-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: add context parameter to all executor methods #31
Conversation
WalkthroughThe pull request introduces modifications across multiple files to the Changes
Assessment against linked issues
Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
fe7b8c5
to
2965472
Compare
0c3b93b
to
bca3072
Compare
The base branch was changed.
This commit adds context.Context as the first parameter to all executor methods and updates relevant function calls and mocks accordingly. This change enhances context propagation and allows for better control over request lifecycles and timeouts. Resolves #25.
bca3072
to
6d6be7c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 10
🧹 Outside diff range and nitpick comments (21)
test/suite.go (4)
25-25
: Consider testing context behavior explicitlyWhile
context.TODO()
works for basic testing, consider adding test cases that verify context cancellation and timeout behavior. This would ensure the context implementation actually provides the intended request lifecycle management.Example test cases to consider:
func (s *ExecutorSuite) TestInitChainWithTimeout() { ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond) defer cancel() // Test timeout scenario _, _, err := s.Exec.InitChain(ctx, time.Now().UTC(), 1, "test-chain") s.Require().Error(err) } func (s *ExecutorSuite) TestInitChainWithCancellation() { ctx, cancel := context.WithCancel(context.Background()) cancel() // Cancel immediately // Test cancellation scenario _, _, err := s.Exec.InitChain(ctx, time.Now().UTC(), 1, "test-chain") s.Require().Error(err) }
33-35
: Enhance test coverage for GetTxsThe test could be improved in two ways:
- Test context behavior (cancellation/timeout) as suggested for InitChain
- Add more specific assertions about the returned transactions
Consider adding assertions like:
func (s *ExecutorSuite) TestGetTxs() { txs, err := s.Exec.GetTxs(context.Background()) s.Require().NoError(err) s.NotNil(txs) // Add more specific assertions s.IsType([]types.Tx{}, txs, "should return correct type") if len(txs) > 0 { s.IsType([]byte{}, txs[0], "each tx should be a byte slice") } }
45-48
: Consider using table-driven tests for ExecuteTxsWhile the basic test case is good, ExecuteTxs is a complex method that would benefit from testing multiple scenarios using table-driven tests.
Example implementation:
func (s *ExecutorSuite) TestExecuteTxs() { tests := []struct { name string txs []types.Tx blockHeight uint64 prevStateRoot types.Hash expectError bool }{ { name: "valid transactions", txs: []types.Tx{[]byte("tx1"), []byte("tx2")}, blockHeight: 1, prevStateRoot: types.Hash{1, 2, 3}, expectError: false, }, { name: "empty transaction list", txs: []types.Tx{}, blockHeight: 1, prevStateRoot: types.Hash{1, 2, 3}, expectError: false, }, // Add more test cases } for _, tt := range tests { s.Run(tt.name, func() { stateRoot, maxBytes, err := s.Exec.ExecuteTxs( context.Background(), tt.txs, tt.blockHeight, time.Now().UTC(), tt.prevStateRoot, ) if tt.expectError { s.Require().Error(err) return } s.Require().NoError(err) s.NotEqual(types.Hash{}, stateRoot) s.Greater(maxBytes, uint64(0)) }) } }
53-54
: Improve SetFinal test coverageThe current test only verifies basic functionality with height 1. Consider testing:
- Context behavior (cancellation/timeout)
- Different height values
- Error cases
Example implementation:
func (s *ExecutorSuite) TestSetFinal() { tests := []struct { name string height uint64 expectError bool }{ {"valid height", 1, false}, {"zero height", 0, true}, {"large height", 1000000, false}, } for _, tt := range tests { s.Run(tt.name, func() { err := s.Exec.SetFinal(context.Background(), tt.height) if tt.expectError { s.Require().Error(err) return } s.Require().NoError(err) }) } }test/dummy.go (2)
28-30
: Consider documenting context usage in commentsWhile this is a dummy implementation, it would be helpful to document that the context parameter is intentionally unused.
-// InitChain initializes the chain state with the given genesis time, initial height, and chain ID. -// It returns the state root hash, the maximum byte size, and an error if the initialization fails. +// InitChain initializes the chain state with the given genesis time, initial height, and chain ID. +// The context parameter is currently unused in this dummy implementation. +// It returns the state root hash, the maximum byte size, and an error if the initialization fails.
33-33
: Consider naming the context parameter for consistencyOther methods use named context parameter (ctx). Consider using the same convention here.
-func (e *DummyExecutor) GetTxs(context.Context) ([]types.Tx, error) { +func (e *DummyExecutor) GetTxs(ctx context.Context) ([]types.Tx, error) {proxy/grpc/proxy_test.go (1)
Line range hint
68-72
: Consider improving the retry mechanismThe current retry mechanism uses hard-coded values and lacks proper error handling. Consider using exponential backoff with proper logging.
+ backoff := 100 * time.Millisecond for i := 0; i < 10; i++ { - if _, err := client.GetTxs(context.TODO()); err == nil { + if _, err := client.GetTxs(ctx); err == nil { break } - time.Sleep(100 * time.Millisecond) + if i < 9 { // Don't log on last attempt + s.T().Logf("Failed to connect on attempt %d: %v", i+1, err) + time.Sleep(backoff) + backoff *= 2 // Exponential backoff + } }proxy/grpc/client_server_test.go (1)
70-73
: Consider using context.Background() instead of context.TODO().While both work, context.Background() is more appropriate here as it explicitly indicates that we're starting a new context hierarchy for testing. context.TODO() is typically used as a placeholder when it's unclear which context to use, which isn't the case in tests.
- stateRoot, maxBytes, err := client.InitChain(context.TODO(), genesisTime, initialHeight, chainID) + stateRoot, maxBytes, err := client.InitChain(context.Background(), genesisTime, initialHeight, chainID)proxy/grpc/server.go (2)
Line range hint
90-94
: Propagate the incoming context for state management operationsExecuteTxs performs critical state modifications. Proper context propagation is essential for managing the lifecycle of these operations, especially for timeout and cancellation handling during state updates.
Apply this change:
updatedStateRoot, maxBytes, err := s.exec.ExecuteTxs( - context.TODO(), + ctx, txs, req.BlockHeight, time.Unix(req.Timestamp, 0), prevStateRoot,
Line range hint
1-114
: Implement consistent context handling across the serverWhile the server correctly uses context for authentication (validateAuth), it systematically fails to propagate contexts to executor calls. Consider implementing the following improvements:
- Add context timeout middleware for all gRPC methods
- Consider adding context logging/tracing for better observability
- Document context handling expectations in method comments
Example middleware implementation:
func (s *Server) withTimeout(ctx context.Context) (context.Context, context.CancelFunc) { return context.WithTimeout(ctx, s.config.RequestTimeout) }Would you like me to provide a complete implementation of these suggestions?
proxy/grpc/client.go (2)
Line range hint
54-65
: Consider adding timeout configuration for InitChain operationWhile the context parameter has been correctly added and propagated, the removal of internal timeout handling could lead to long-running operations. Consider adding a default timeout configuration option in the Client config.
type Config struct { + InitChainTimeout time.Duration // existing fields... } func DefaultConfig() *Config { return &Config{ + InitChainTimeout: 30 * time.Second, // existing defaults... } }
Line range hint
54-114
: Consider adding context handling middlewareTo ensure consistent context handling across all methods, consider implementing middleware that:
- Validates context presence and timeout configuration
- Adds logging/tracing for context cancellations
- Implements consistent retry policies
- Provides metrics for context-related failures
This would centralize the context handling logic and make it easier to maintain.
Would you like me to provide an example implementation of the context handling middleware?
proxy/jsonrpc/client_server_test.go (5)
52-52
: Consider using a proper context instead of context.TODO()While the changes correctly implement the context parameter, using
context.TODO()
in tests might not be the best practice. Consider usingcontext.Background()
or a context with timeout for more realistic testing scenarios.- stateRoot, maxBytes, err := client.InitChain(context.TODO(), genesisTime, initialHeight, chainID) + ctx, cancel := context.WithTimeout(context.Background(), config.DefaultTimeout) + defer cancel() + stateRoot, maxBytes, err := client.InitChain(ctx, genesisTime, initialHeight, chainID)Also applies to: 55-55
65-65
: Maintain consistent context handling across test casesSimilar to the InitChain test, consider using a proper context with timeout instead of
context.TODO()
.- txs, err := client.GetTxs(context.TODO()) + ctx, cancel := context.WithTimeout(context.Background(), config.DefaultTimeout) + defer cancel() + txs, err := client.GetTxs(ctx)Also applies to: 67-67
90-90
: Maintain consistent context handling in ExecuteTxs testThe context parameter is correctly added, but consider using a proper context with timeout instead of
context.TODO()
.- updatedStateRoot, maxBytes, err := client.ExecuteTxs(context.TODO(), txs, blockHeight, timestamp, prevStateRoot) + ctx, cancel := context.WithTimeout(context.Background(), config.DefaultTimeout) + defer cancel() + updatedStateRoot, maxBytes, err := client.ExecuteTxs(ctx, txs, blockHeight, timestamp, prevStateRoot)Also applies to: 93-93
103-103
: Consider refactoring context creation into a test helperThe context parameter is correctly added, but there's repeated context creation pattern across all tests. Consider creating a test helper function for consistent context handling.
+ // Add at the beginning of the test file + func createTestContext(t *testing.T, timeout time.Duration) (context.Context, context.CancelFunc) { + return context.WithTimeout(context.Background(), timeout) + } - err := client.SetFinal(context.TODO(), blockHeight) + ctx, cancel := createTestContext(t, config.DefaultTimeout) + defer cancel() + err := client.SetFinal(ctx, blockHeight)Also applies to: 105-105
Context handling needs improvement in test coverage
The test suite currently lacks comprehensive context handling tests. While timeouts are configured in the client/server setup, there are no explicit test cases for:
- Context timeout scenarios
- Context cancellation behavior
- Error propagation when context deadlines are exceeded
- Edge cases around context values and propagation
Key locations requiring attention:
proxy/jsonrpc/client_server_test.go
: Add timeout and cancellation test cases for each RPC methodproxy/jsonrpc/proxy_test.go
: Enhance context deadline tests beyond basic configuration- Consider adding similar context tests as implemented in
proxy/grpc/proxy_test.go
🔗 Analysis chain
Line range hint
1-109
: Overall context implementation looks good with room for improvementThe changes successfully implement the context parameter across all executor methods, aligning well with the PR objectives. However, there are opportunities to improve the test suite:
- Consider implementing context timeout tests to verify proper timeout handling
- Add test cases for context cancellation scenarios
- Consider testing context propagation to ensure the context is properly passed through the execution chain
Let's verify if there are any timeout or cancellation tests in the codebase:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for timeout-related tests echo "Searching for timeout-related tests..." rg -l "WithTimeout|context.*cancel|Timeout" --type go --glob "*_test.go" # Search for context cancellation tests echo "Searching for context cancellation tests..." rg -l "cancel\(\)|Done\(\)" --type go --glob "*_test.go"Length of output: 464
Script:
#!/bin/bash # Let's examine the actual timeout and cancellation test implementations echo "Checking timeout tests in jsonrpc client_server_test.go:" rg "WithTimeout|context.*cancel|Timeout" -B 2 -A 5 proxy/jsonrpc/client_server_test.go echo -e "\nChecking timeout tests in jsonrpc proxy_test.go:" rg "WithTimeout|context.*cancel|Timeout" -B 2 -A 5 proxy/jsonrpc/proxy_test.go echo -e "\nChecking context cancellation tests in grpc proxy_test.go:" rg "cancel\(\)|Done\(\)" -B 2 -A 5 proxy/grpc/proxy_test.goLength of output: 1276
proxy/jsonrpc/server.go (3)
Line range hint
33-83
: Update method signatures to include context parameter.The PR objective is to add context parameters to all methods, but the handler methods don't accept context. Update the signatures to accept context from ServeHTTP.
Example refactor:
- func (s *Server) handleInitChain(params json.RawMessage) (interface{}, *jsonRPCError) { + func (s *Server) handleInitChain(ctx context.Context, params json.RawMessage) (interface{}, *jsonRPCError) { // In ServeHTTP: switch request.Method { case "init_chain": - result, err = s.handleInitChain(request.Params) + result, err = s.handleInitChain(r.Context(), request.Params)
Line range hint
194-195
: Implement proper error handling with context.The TODO comment about error handling becomes more critical with context propagation. Consider implementing:
- Context deadline exceeded errors
- Request cancellation handling
- Proper error logging with request context
Would you like me to propose a comprehensive error handling implementation that integrates with the context changes?
Context error handling needs to be implemented
The codebase currently:
- Uses
context.TODO()
in all RPC handler methods, which means no timeout or cancellation handling- Has no mapping between context errors and JSON-RPC error codes
- Only maps generic errors to
ErrCodeInternal
Required changes:
- Replace
context.TODO()
with request context from HTTP handler- Add proper error mapping for
context.Canceled
andcontext.DeadlineExceeded
- Consider adding a new error code for context-related failures
🔗 Analysis chain
Line range hint
33-83
: Verify context error handling in JSON-RPC responses.Ensure that context cancellation and timeout errors are properly mapped to appropriate JSON-RPC error codes.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for error handling patterns in the codebase echo "Searching for JSON-RPC error definitions..." rg "type.*jsonRPCError" -A 5 echo "Searching for context error handling patterns..." rg "context\.(Canceled|DeadlineExceeded)"Length of output: 523
Script:
#!/bin/bash # Let's check the error definitions and their usage echo "Checking error constants and their values..." rg "var|const.*Err" proxy/jsonrpc/errors.go -A 3 echo "Checking where these errors are used..." rg "writeError\(.*Err.*\)" proxy/jsonrpc/ echo "Checking context usage in server methods..." ast-grep --pattern 'func \(s \*Server\) handle.*\(.*context\.Context.*\) \{'Length of output: 947
Script:
#!/bin/bash # Let's check all error definitions and error handling patterns echo "Checking all error constants..." cat proxy/jsonrpc/errors.go echo "Checking error handling in server methods..." rg "func.*handle.*" proxy/jsonrpc/server.go -A 10 echo "Checking if context is used in the request processing..." rg "context\." proxy/jsonrpc/server.goLength of output: 3700
proxy/jsonrpc/client.go (1)
Line range hint
1-194
: Consider enhancing context handling with middleware and validation.To improve the robustness of the context handling, consider:
- Adding context timeout validation to ensure the provided context timeout doesn't exceed the client's default timeout
- Implementing middleware for common context handling logic (logging, metrics, etc.)
- Adding context cancellation checks in long-running operations
Example timeout validation:
func validateTimeout(ctx context.Context, defaultTimeout time.Duration) error { if deadline, ok := ctx.Deadline(); ok && deadline.Sub(time.Now()) > defaultTimeout { return fmt.Errorf("context deadline %v exceeds default timeout %v", deadline, defaultTimeout) } return nil }Would you like me to provide a more detailed implementation of these suggestions?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (11)
execution.go
(2 hunks)mocks/mock_Executor.go
(12 hunks)proxy/grpc/client.go
(4 hunks)proxy/grpc/client_server_test.go
(3 hunks)proxy/grpc/proxy_test.go
(1 hunks)proxy/grpc/server.go
(4 hunks)proxy/jsonrpc/client.go
(7 hunks)proxy/jsonrpc/client_server_test.go
(5 hunks)proxy/jsonrpc/server.go
(5 hunks)test/dummy.go
(2 hunks)test/suite.go
(3 hunks)
🔇 Additional comments (20)
execution.go (3)
4-4
: LGTM: Context import added correctly.
The context
package import is necessary for the interface changes and follows Go's import conventions.
13-22
: LGTM: Context parameter consistently added to all Executor methods.
The changes follow Go's best practices by:
- Adding context as the first parameter
- Maintaining consistent method signatures
- Preserving return types for backward compatibility
13-22
: Verify context handling in implementations.
Please ensure that all implementations properly handle the context:
- Respect context cancellation
- Propagate timeouts appropriately
- Handle context values if needed
Let's verify the implementations:
test/suite.go (2)
4-4
: LGTM: Context import added correctly
The context import is appropriately placed with standard library imports and is necessary for the context parameter additions.
25-25
: Verify complete context implementation coverage
Let's verify that all executor methods that should have context parameters have been updated.
Also applies to: 33-33, 45-45, 53-53
✅ Verification successful
Let me gather more information to verify the context implementation coverage comprehensively.
All context parameters properly implemented
Based on the verification results:
- The Executor interface defines 4 methods that require context:
InitChain
,GetTxs
,ExecuteTxs
, andSetFinal
- All calls to these methods in test/suite.go correctly pass context.TODO()
- The interface definition shows all methods have the context parameter as their first argument
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for any remaining executor method definitions that might be missing context
ast-grep --pattern 'interface Executor {
$$$
$method($params) $ret {
$$$
}
$$$
}'
# Search for any method calls that might still be using old signatures
rg "s\.Exec\." --type go
Length of output: 470
Script:
#!/bin/bash
# Search for the Executor interface definition to see all required methods
rg "type Executor interface" -A 20 --type go
# Search for any executor implementations to verify context usage
ast-grep --pattern 'type $_ struct {
$$$
}
func (e $_) $_($params) $_ {
$$$
}'
Length of output: 1042
test/dummy.go (4)
4-4
: LGTM: Context import added correctly
38-41
: LGTM: Context parameter correctly added
The implementation maintains the expected behavior while adding context support.
44-46
: LGTM: Context parameter correctly added to unimplemented method
Line range hint 1-46
: Verify interface implementation completeness
Let's ensure all Executor interface methods have been updated with context parameter.
✅ Verification successful
All interface methods are correctly implemented with context parameter
Comparing the Executor interface methods with DummyExecutor implementations:
InitChain
: ✓ Implemented with correct context and parametersGetTxs
: ✓ Implemented with context parameterExecuteTxs
: ✓ Implemented with correct context and parametersSetFinal
: ✓ Implemented with correct context and parameter
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify that all Executor interface methods are implemented with context parameter
# Expected: All interface methods should have corresponding implementations with context
# Search for interface definition
echo "=== Executor Interface Methods ==="
ast-grep --pattern 'type Executor interface {
$$$
}'
# Search for DummyExecutor implementations
echo -e "\n=== DummyExecutor Implementations ==="
ast-grep --pattern 'func (e *DummyExecutor) $_($$$) $_'
Length of output: 2065
proxy/grpc/client_server_test.go (2)
4-4
: LGTM: Context import added correctly.
The context import is necessary for using context.TODO() in the test cases.
70-73
: Verify consistent context parameter addition across all executor methods.
The changes here look good, but let's verify that all executor methods consistently have context as their first parameter across the codebase.
✅ Verification successful
Let me gather more information about the implementations to ensure completeness of the verification.
Context parameter is consistently implemented across all executor methods
Based on the comprehensive search results, all Executor interface methods (InitChain
, GetTxs
, ExecuteTxs
, and SetFinal
) consistently have context.Context
as their first parameter across all implementations:
- Interface definition in
execution.go
- Concrete implementations in
test/dummy.go
- Client implementations in
proxy/grpc/client.go
andproxy/jsonrpc/client.go
- Server implementations in
proxy/grpc/server.go
- Mock implementations in
mocks/mock_Executor.go
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check all executor method signatures to ensure consistent context parameter addition
# Check interface definition
echo "Checking Executor interface definition:"
rg -A 10 "type Executor interface" --type go
# Check implementations
echo "Checking executor method implementations:"
ast-grep --pattern 'func ($x *$_) $method($params) $_ {
$$$
}'
Length of output: 1120
Script:
#!/bin/bash
# Search for all executor method implementations
echo "Searching for InitChain implementations:"
rg "func.*InitChain.*context\.Context.*\)" --type go -A 2
echo -e "\nSearching for GetTxs implementations:"
rg "func.*GetTxs.*context\.Context.*\)" --type go -A 2
echo -e "\nSearching for ExecuteTxs implementations:"
rg "func.*ExecuteTxs.*context\.Context.*\)" --type go -A 2
echo -e "\nSearching for SetFinal implementations:"
rg "func.*SetFinal.*context\.Context.*\)" --type go -A 2
Length of output: 11732
proxy/grpc/client.go (3)
Line range hint 71-82
: LGTM! Clean context implementation
The context parameter has been correctly added and propagated to the gRPC call. The implementation maintains good error handling practices.
Line range hint 86-106
: Document context usage expectations for ExecuteTxs
This is a critical path for transaction processing. Consider adding documentation about:
- Expected context timeout values
- Handling of context cancellation during execution
- Impact on state consistency if context is cancelled mid-execution
Let's check if there are any existing timeout configurations or context handling patterns in the codebase:
Line range hint 109-114
: Consider finality guarantees with context cancellation
Since this method affects block finality, it's important to ensure proper handling of context cancellation. Consider:
- Adding retry logic for temporary failures
- Documenting the finality guarantees when context is cancelled
Let's check for existing retry patterns in the codebase:
proxy/jsonrpc/client_server_test.go (1)
4-4
: LGTM: Context import added correctly
The context import is appropriately added to support the new context parameter requirements.
proxy/jsonrpc/server.go (1)
4-4
: LGTM: Context import added correctly.
proxy/jsonrpc/client.go (1)
143-143
: LGTM! Context is properly used in the HTTP request.
The internal implementation correctly uses the context for HTTP request creation, which will properly handle request cancellation and timeouts.
Also applies to: 161-161
mocks/mock_Executor.go (3)
6-6
: LGTM: Context import added correctly
The context import is appropriately added to support the new context parameter in method signatures.
30-31
: LGTM: Method signatures updated consistently
All executor methods have been correctly updated to include context.Context
as their first parameter while maintaining:
- Consistent parameter naming (ctx)
- Original parameter order
- Original return types
Also applies to: 99-100, 157-158, 225-226
41-42
: Verify mock implementations in tests
The mock implementations have been correctly updated to handle the context parameter. To ensure the changes work as expected, verify that:
- All existing tests are updated to pass context
- Mock expectations correctly capture and verify context values
Also applies to: 44-45, 52-53, 58-59, 82-84, 94-94, 109-110, 112-113, 120-121, 140-142, 152-152, 168-169, 171-172, 179-180, 185-186, 208-210, 220-220, 234-235, 255-257, 267-267
✅ Verification successful
Mock implementations are correctly used with context in tests
The test files show that:
- All test calls properly pass context.Context (using context.TODO())
- Mock expectations correctly capture and verify context using mock.Anything
- All executor methods (ExecuteTxs, GetTxs, InitChain, SetFinal) are tested with proper context handling
Examples from the tests:
- InitChain:
mockExec.On("InitChain", mock.Anything, expectedTime, initialHeight, chainID)
- GetTxs:
mockExec.On("GetTxs", mock.Anything)
- ExecuteTxs:
mockExec.On("ExecuteTxs", mock.Anything, txs, blockHeight, expectedTime, prevStateRoot)
- SetFinal:
mockExec.On("SetFinal", mock.Anything, blockHeight)
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify that tests are updated to use context with mock executor
# Test: Search for mock executor usage in tests
echo "Searching for mock executor usage in tests..."
rg -l "NewMockExecutor" --glob "**/*_test.go"
# Test: Verify context is passed in test calls
echo "Verifying context usage in test calls..."
rg "mock.(ExecuteTxs|GetTxs|InitChain|SetFinal)" --glob "**/*_test.go" -A 2
Length of output: 384
Script:
#!/bin/bash
# Let's examine the test files that use mock executor more closely
echo "Content of proxy/grpc/client_server_test.go:"
cat proxy/grpc/client_server_test.go
echo -e "\nContent of proxy/jsonrpc/client_server_test.go:"
cat proxy/jsonrpc/client_server_test.go
# Let's also check for any test setup or mock initialization
echo -e "\nSearching for mock setup patterns:"
rg "mock := .+NewMockExecutor|executor := .+NewMockExecutor" -A 3
Length of output: 5893
Overview
This commit adds context.Context as the first parameter to all executor methods and updates relevant function calls and mocks accordingly. This change enhances context propagation and allows for better control over request lifecycles and timeouts.
Resolves #25.
Summary by CodeRabbit
New Features
Bug Fixes
Documentation